<template>
	<view>
		<u-sticky bgColor="#6492FF" offsetTop=0 customNavHeight=0>
			<navbox :title="title"></navbox>
		</u-sticky>
		<view class="list" v-if="list.length>0">
			<view class="list__item" v-for="(item,index) in list" :key="index" @click="navto('/pages/home/noticeinfo?id='+item.noticeId)">
				<image :src="item.noticeImg?item.noticeImg:'/static/img/home/tg.png'" class="list__item__pic" mode="widthFix"></image>
				<view class="list__item__right">
					<view class="list__item__name">
						{{item.noticeTitle}}
					</view>
					<view class="list__item__content">
						{{item.descInfo}}
					</view>
				</view>
			</view>
			<u-loadmore @loadmore="loadmore" :status="morestatus" />
		</view>
		<view class="" v-else style="margin-top: 200rpx;">
			<u-empty icon="/static/img/index/empty.png" mode="data" text="暂时没有数据"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		noticelist
	} from '@/api/home.js'
	export default {
		data() {
			return {
				title: '',
				pageSize: 10,
				pageNum: 1,
				list: [],
				type:0,
				morestatus: 'loadmore',
			};
		},
		methods: {
			getlist() {
				noticelist({
					noticeType:this.type,
					pageSize: this.pageSize,
					pageNum: this.pageNum
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.data.code == 200) {
						if (res.data.data.length == 0) {
							this.morestatus = 'nomore';
							return
						}else{
							this.morestatus = 'loadmore';
						}
						this.list = [...this.list, ...res.data.data]
					}
				})
			},
			loadmore(){
				if(this.morestatus=='nomore')return
				this.morestatus = 'loading';
				this.pageNum = ++this.pageNum;
				this.getlist()
			}
		},
		onLoad(option) {
			this.type=option.type
			this.title = option.title
			this.getlist()
		},
		onReachBottom() {
			this.loadmore()
		},
		onPullDownRefresh() {
			this.morestatus='loadmore'
			this.pageNum=1
			this.list=[]
			this.getlist()
		}
	}
</script>

<style lang="scss">
	.list {
		padding-bottom: 30rpx;

		&__item {
			padding: 30rpx 64rpx 25rpx 16rpx;
			display: flex;
			align-items: center;
			border-bottom: 1rpx solid #D8D8D8;

			&__pic {
				width: 208rpx;
				height: 139rpx;
				margin-right: 45rpx;
				flex-shrink: 0;
			}

			&__right {
				height: 139rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
			}

			&__name {

				font-family: Source Han Sans SC;
				font-weight: bold;
				font-size: 33rpx;
				color: #3E3D3D;
				line-height: 33rpx;
			}

			&__content {
				font-family: Source Han Sans SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #707070;
				line-height: 26rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				width: 416.67rpx;
				margin-top: 27rpx;
			}
		}
	}
</style>